package com.example.exam.logInfo.service;

import com.example.exam.db.PageInfoBean;
import com.example.exam.logInfo.dao.LogInfoDao;
import com.example.exam.logInfo.model.LogInfoBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("logInfoService")
public class LogInfoService {
    @Autowired
    LogInfoDao lid;
    /**
     * @Description:插入日志
     * @Param: [lib]
     * @return: java.lang.Integer
     * @Author: xhw
     * @Date: 2021/7/26
     */
    public Integer insertLog(LogInfoBean lib){

       int i=lid.add(lib);
       if(i>0){
           return 1;
       }else{
           return 0;
       }
    }
    /**
     * @Description:得到日志列表页面的数据
     * @Param: [page, limit, beginTime, endTime]
     * @return: com.example.exam.db.PageInfoBean
     * @Author: xhw
     * @Date: 2021/7/26
     */
    public PageInfoBean toList(Integer page, Integer limit, String beginTime, String endTime) {

        PageInfoBean pageInfo = new PageInfoBean();
        try {
            pageInfo.setPerPage(limit);
            if (page  != null) {
                pageInfo.setCurPage(page);
            }
            PageInfoBean pageInfoBean = lid.getOpLogList(pageInfo,beginTime,endTime);
            return pageInfoBean;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
